home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8708 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  47 lines

  1. Path: aimnet.aimnet.com!not-for-mail
  2. From: krisb@aimnet.com (Kris Bosland)
  3. Newsgroups: comp.lang.c++
  4. Subject: Template Troubles
  5. Date: 25 Feb 1996 20:11:23 -0800
  6. Organization: Aimnet Corp.
  7. Distribution: usa
  8. Message-ID: <4grbtb$nog@aimnet.aimnet.com>
  9. NNTP-Posting-Host: aimnet.aimnet.com
  10.  
  11.     I have just discovered Templates in C++, and I am trying to use them 
  12. for the same thing that everyone else uses them for: Linked Lists.  I am 
  13. trying to get even a basic template class going, and it is not working.  I am 
  14. running g++ 2.7.0 on my Linux 1.2.13 system (vanilla Slackware 3.0).  Files:
  15.  
  16. test.cc:
  17. ----------------------------------------------------------------
  18. template <class data_t> class List {
  19.   public:
  20.     data_t data;
  21. }
  22.  
  23. void main( int argc, char **argv )
  24. {
  25.   List<char *> string_list;
  26.  
  27. }
  28. ----------------------------------------------------------------
  29.  
  30. Compiler Results:
  31. ----------------------------------------------------------------
  32. g++ -g -o test test.cc
  33. test.cc:7: parse error before `void'
  34. test.cc:9: confused by earlier errors, bailing out
  35. make: *** [test] Error 1
  36. ----------------------------------------------------------------
  37.  
  38.     Could I be missing some compiler flags or configuration?  I don't have 
  39. much experience customizing gcc/g++.  In a more complicated file I wrote, I 
  40. got errors complaining about incomplete typing of the data member of my class.
  41.  
  42.  
  43.  
  44.                     -Kris Bosland
  45.                      krisb@aimnet.com
  46.                      http://www.seattleu.edu/~krisb/
  47.